home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / sources / memoryclasstest.cp < prev    next >
Encoding:
Text File  |  2000-09-28  |  2.9 KB  |  85 lines

  1. /*
  2.     File:        MemoryClassTest.cp
  3.  
  4.     Contains:    TMemory is a simple object checks heap and stack values, as well as changes them.
  5.                   TMemoryClassTest.cp contains the TMemory class test functions.
  6.  
  7.     Written by:    Kent Sandvik     
  8.  
  9.     Copyright:    Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24.  
  25. #ifndef _MEMORYCLASS_
  26. #include "MemoryClass.h"
  27. #endif
  28.  
  29. // CONSTANTS
  30. const long kMyMinHeap = 200 * 1024;
  31. const long kMyMinStack = 60 * 1024;
  32.  
  33. // We will test out various stack and heap sizes. It is recommended to make a separate
  34. // application (SIOW or something similar) for testing this out. Don't forget to add the
  35. // special kStackResource -- the test program needs this one.
  36.  
  37. void main(void)
  38. {
  39.     cout << "Start of the TMemory object test…\n";
  40.  
  41.     // Create a TMemory object.    
  42.     TMemory myMemory(kMyMinHeap, kMyMinStack);
  43.  
  44.     // Check out current sizes.
  45.     cout << "Current Stack size is = " << myMemory.GetStackSize() << '\n';
  46.     cout << "Current Heap size is = " << myMemory.GetHeapSize() << '\n';
  47.  
  48.     // Change stack size.
  49.     cout << "I'm changing the stack size to 60k \n";
  50.     myMemory.SetStackSize(60 * 1024);
  51.     cout << "New Stack size is = " << myMemory.GetStackSize() << '\n';
  52.     cout << "I'm increasing the stack size by 10k \n";
  53.     myMemory.IncreaseStackSize(10 * 1024);
  54.     cout << "New Stack size is = " << myMemory.GetStackSize() << '\n';
  55.     cout << "Current Heap size is = " << myMemory.GetHeapSize() << '\n';
  56.  
  57.     // Check heap size values, valid?
  58.     if (myMemory.CheckHeapSize())
  59.         cout << "OK with the heap size, > 200k\n";
  60.     else
  61.         cout << "Problems with the heap size, < 200k\n";
  62.  
  63.     // Check stack size values, valid?
  64.     if (myMemory.CheckStackSize())
  65.         cout << "OK with the stack size, > 60k\n";
  66.     else
  67.         cout << "Problems with the stack size, < 60k\n";
  68.  
  69.     // Test of resource handling
  70.     if (myMemory.SetStackSizeFromResources())
  71.         cout << "OK with setting the stack size from resources, stack size = " << myMemory.GetStackSize() << '\n';
  72.     else
  73.         cout << "No resources, couldn't set stack size from a resource value\n";
  74.  
  75.     cout << "End of the TMemory object test!\n";
  76. }
  77.  
  78. // _________________________________________________________________________________________________________ //
  79.  
  80. /*    Change History (most recent last):
  81.   No        Init.    Date        Comment
  82.   1            khs        1/2/93        New file
  83.   2            khs        1/3/93        Cleanup
  84. */
  85.